//
//  Dao.h
//  MarketOverview
//
//  Created by madmin on 10-8-16.
//  Copyright 2010 thomsonreuters.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "BabyActivityEntry.h"
#import "BabyGrowEntry.h"
#import "BabyProfile.h"
#import "BabyActivityReportEntry.h"
#import "BabyPhotoEntry.h"
#import <stdio.h>
#import <fcntl.h>

#define kFilename      @"data.sqlite4"

@interface Dao : NSObject {
	sqlite3     *_pDB;
}

-(NSString *)dataFilePath;

+(Dao *) getInstance;

-(void)QueryBabyActivityWith:(NSString *) whereClause records:(NSMutableArray *)records;

-(void)RemoveBabyActivityEntry:(BabyActivityEntry *)pv;

-(void)RemoveBabyActivityWithName:(NSString *)name;

-(void)InsertBabyActivity:(BabyActivityEntry *)entry;

-(void)UpdateBabyActivityEntry:(BabyActivityEntry *)entry;

-(int)GetCountUnderCondition:(NSString *)columnName condition:(NSString *)condition;

-(int)GetSumUnderCondition:(NSString *)columnName condition:(NSString *)condition;

-(void)GetReportSummaryWithStartEndDate:(NSDate *)startDate endDate:(NSDate *)endDate report:(BabyActivityReportEntry *)report;

-(void)LoadBabyProfile:(BabyProfile *)babyProfile;

-(void)GetDayReport:(NSDate *) date report:(BabyActivityReportEntry *)report;

-(void)SaveAllBabyEntriesToFile;

-(NSString *)GetCategoryName:(int)Category;

//For Grow Entry
-(BabyGrowEntry *) QueryBabyGrowEntryWithGrowID:(int)ID;

-(void)QueryBabyGrowEntryWith:(NSString *) whereClause records:(NSMutableArray *)records;

-(void)RemoveBabyGrowEntry:(BabyGrowEntry *)entry;

-(int)InsertBabyGrowEntry:(BabyGrowEntry *)entry;

-(void)UpdateBabyGrowEntry:(BabyGrowEntry *)entry;

-(NSString *)GetAgeStringWithTwoDate:(double)fromDateTS toDateTS:(double)toDateTS;

//For BabyPhoto Entry
-(void)QueryBabyPhotoEntryWith:(NSString *) whereClause records:(NSMutableArray *)records;

-(void)RemoveBabyPhotoEntry:(BabyPhotoEntry *)entry;

-(int)InsertBabyPhotoEntry:(BabyPhotoEntry *)entry;

-(void)UpdateBabyPhotoEntry:(BabyPhotoEntry *)entry;

//For Photo Category Entry
-(void)QueryPhotoCategoryEntryWith:(NSString *) whereClause records:(NSMutableArray *)records;

-(void)RemovePhotoCategoryEntry:(PhotoAlbumEntry *)entry;

-(void)InsertPhotoCategoryEntry:(PhotoAlbumEntry *)entry;

-(void)UpdatePhotoCategoryEntry:(PhotoAlbumEntry *)entry;
@end
